package com.digitalchina.lxnsy.viewholder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.OperationRecordsVO;
import com.digitalchina.lxnsy.entity.SchemaJsonVO;
import com.digitalchina.lxnsy.interfaces.IMyNhbPos;
import com.digitalchina.lxnsy.toolkit.JointImageUrl;
import com.digitalchina.lxnsy.toolkit.StringUtil;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.lzy.ninegrid.ImageInfo;
import com.lzy.ninegrid.NineGridView;
import com.lzy.ninegrid.preview.NineGridViewClickAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：郑皓
 * 创建时间：2018/8/28 20:10
 * 修改备注：
 * ================================================
 */

public class FarmingRecordFertilizerHolderV3 extends BaseViewHolder<OperationRecordsVO> {

    private TextView tvTime;
    private TextView tvType;
    private TextView tvWeather;
    private TextView tvWhq;

    private NineGridView nineGridView;
    private TextView tvMsgInfo;

    private TextView tvMu;
    private TextView tvWorkTime;
    private TextView tvPeopleNum;
    private TextView tvMember;


    private TextView tvEdit;
    private TextView tvDelete;

    private TextView tvVariety;
    private TextView tvLand;


    private IMyNhbPos callBack;


    //layout
    private RelativeLayout layoutJichu;
    private LinearLayout layoutJichuAdd;
    private TextView tv1a, tv1b;
    private ImageView iv1;
    private RelativeLayout layoutNongyao;
    private LinearLayout layoutNongyaoAdd;
    private TextView tv2a, tv2b;
    private ImageView iv2;
    private RelativeLayout layoutHuafei;
    private LinearLayout layoutHuafeiAdd;
    private TextView tv3a, tv3b;
    private ImageView iv3;
    private RelativeLayout layoutDapeng;
    private LinearLayout layoutDapengAdd;
    private TextView tv4a, tv4b;
    private ImageView iv4;
    private RelativeLayout layoutJixie;
    private LinearLayout layoutJixieAdd;
    private TextView tv5a, tv5b;
    private ImageView iv5;
    private RelativeLayout layoutTouru;
    private LinearLayout layoutTouruAdd;
    private TextView tv6a, tv6b;
    private ImageView iv6;
    private RelativeLayout layoutFangfa;
    private LinearLayout layoutFangfaAdd;
    private TextView tv7a, tv7b;
    private ImageView iv7;
    private RelativeLayout layoutCaishou;
    private LinearLayout layoutCaishouAdd;
    private TextView tv8a, tv8b;
    private ImageView iv8;
    private RelativeLayout layoutJiagong;
    private LinearLayout layoutJiagongAdd;
    private TextView tv9a, tv9b;
    private ImageView iv9;
    private RelativeLayout layoutDingzhi;
    private LinearLayout layoutDingzhiAdd;
    private TextView tv10a, tv10b;
    private ImageView iv10;

    private LinearLayout layoutParent1;
    private LinearLayout layoutParent2;
    private LinearLayout layoutParent3;
    private LinearLayout layoutParent4;
    private LinearLayout layoutParent5;
    private LinearLayout layoutParent6;
    private LinearLayout layoutParent7;
    private LinearLayout layoutParent8;
    private LinearLayout layoutParent9;


    public FarmingRecordFertilizerHolderV3(ViewGroup parent, IMyNhbPos callBack) {
        super(parent, R.layout.item_farming_record_v3);
        tvTime = $(R.id.tv_time);
        tvType = $(R.id.tv_type);
        tvWeather = $(R.id.tv_weather);
        tvWhq = $(R.id.tv_whq);


        nineGridView = $(R.id.nineGrid);
        tvMsgInfo = $(R.id.tv_msg_info);

        //基础信息
        tvMu = $(R.id.tv_mu);
        tvWorkTime = $(R.id.tv_work_time);
        tvPeopleNum = $(R.id.tv_people_num);
        tvMember = $(R.id.tv_member);


        tvEdit = $(R.id.tv_edit);
        tvDelete = $(R.id.tv_delete);

        tvVariety = $(R.id.tv_variety);
        tvLand = $(R.id.tv_land);


        //展开收起layout
        layoutJichu = $(R.id.layout_jichu);
        layoutJichuAdd = $(R.id.layout_jichu_add);
        tv1a = $(R.id.tv1a);
        tv1b = $(R.id.tv1b);
        iv1 = $(R.id.iv1);
        layoutNongyao = $(R.id.layout_nongyao);
        layoutNongyaoAdd = $(R.id.layout_nongyao_add);
        tv2a = $(R.id.tv2a);
        tv2b = $(R.id.tv2b);
        iv2 = $(R.id.iv2);
        layoutHuafei = $(R.id.layout_huafei);
        layoutHuafeiAdd = $(R.id.layout_huafei_add);
        tv3a = $(R.id.tv3a);
        tv3b = $(R.id.tv3b);
        iv3 = $(R.id.iv3);
        layoutDapeng = $(R.id.layout_dapeng);
        layoutDapengAdd = $(R.id.layout_dapeng_add);
        tv4a = $(R.id.tv4a);
        tv4b = $(R.id.tv4b);
        iv4 = $(R.id.iv4);
        layoutJixie = $(R.id.layout_jixie);
        layoutJixieAdd = $(R.id.layout_jixie_add);
        tv5a = $(R.id.tv5a);
        tv5b = $(R.id.tv5b);
        iv5 = $(R.id.iv5);
        layoutTouru = $(R.id.layout_touru);
        layoutTouruAdd = $(R.id.layout_touru_add);
        tv6a = $(R.id.tv6a);
        tv6b = $(R.id.tv6b);
        iv6 = $(R.id.iv6);
        layoutFangfa = $(R.id.layout_fangfa);
        layoutFangfaAdd = $(R.id.layout_fangfa_add);
        tv7a = $(R.id.tv7a);
        tv7b = $(R.id.tv7b);
        iv7 = $(R.id.iv7);
        layoutCaishou = $(R.id.layout_caishou);
        layoutCaishouAdd = $(R.id.layout_caishou_add);
        tv8a = $(R.id.tv8a);
        tv8b = $(R.id.tv8b);
        iv8 = $(R.id.iv8);
        layoutJiagong = $(R.id.layout_jiagong);
        layoutJiagongAdd = $(R.id.layout_jiagong_add);
        tv9a = $(R.id.tv9a);
        tv9b = $(R.id.tv9b);
        iv9 = $(R.id.iv9);
        layoutDingzhi = $(R.id.layout_dingzhi);
        layoutDingzhiAdd = $(R.id.layout_dingzhi_add);
        tv10a = $(R.id.tv10a);
        tv10b = $(R.id.tv10b);
        iv10 = $(R.id.iv10);


        layoutParent1 = $(R.id.layout_parent1);
        layoutParent2 = $(R.id.layout_parent2);
        layoutParent3 = $(R.id.layout_parent3);
        layoutParent4 = $(R.id.layout_parent4);
        layoutParent5 = $(R.id.layout_parent5);
        layoutParent6 = $(R.id.layout_parent6);
        layoutParent7 = $(R.id.layout_parent7);
        layoutParent8 = $(R.id.layout_parent8);
        layoutParent9 = $(R.id.layout_parent9);

        this.callBack = callBack;
    }

    @Override
    public void setData(final OperationRecordsVO data) {
        super.setData(data);

        // 公共部分
        // 时间
        tvTime.setText(data.getOperationDate());
        // 天气
        tvWeather.setText("天气：" + data.getWeather() + " " + data.getWeatherDescribe());
        // 物候期
        tvWhq.setText(data.getPhaseName());
        // 补充说明
        if (StringUtil.isStrEmpty(data.getSpecification())) {
            tvMsgInfo.setVisibility(View.GONE);
        } else {
            tvMsgInfo.setVisibility(View.VISIBLE);
            tvMsgInfo.setText(data.getSpecification() + "");
        }

        //农事操作
        tvType.setText(data.getFarmOperationName());

        //品种
        tvVariety.setText("品种：" + data.getVarietyName());

        //地块
        if (StringUtil.isStrEmpty(data.getLandName())) {
            tvLand.setVisibility(View.GONE);
        } else {
            tvLand.setVisibility(View.VISIBLE);
            tvLand.setText("地块：" + data.getLandName());
        }


        //基础信息
        tvMu.setText(data.getMuNumber());
        tvWorkTime.setText(data.getHours());
        tvPeopleNum.setText(data.getPeopleNum());
        tvMember.setText(data.getMember());


        // 图片展示
        if (data.getFarmingOperationsimgs() != null && data.getFarmingOperationsimgs().size() > 0) {
            nineGridView.setVisibility(View.VISIBLE);
            ArrayList<ImageInfo> imageInfo = new ArrayList<>();

            for (int i = 0; i < data.getFarmingOperationsimgs().size(); i++) {
                ImageInfo info = new ImageInfo();
                info.setThumbnailUrl(JointImageUrl.smallImageUrl(data.getFarmingOperationsimgs().get(i).getImage()));
                info.setBigImageUrl(JointImageUrl.bigImageUrl(data.getFarmingOperationsimgs().get(i).getImage()));
                imageInfo.add(info);
            }
            nineGridView.setAdapter(new NineGridViewClickAdapter(getContext(), imageInfo));

        } else {
            nineGridView.setVisibility(View.GONE);
        }


        if (data.getAgriculturalOperationSchemeVO() != null) {
            //农药
            List<SchemaJsonVO> list1 = data.getAgriculturalOperationSchemeVO().getPesticideSchemeList();
            if ((list1 != null && list1.size() > 0)) {
                layoutNongyaoAdd.removeAllViews();
                layoutParent1.setVisibility(View.VISIBLE);

                for (int i = 0; i < list1.size(); i++) {
                    View view = View.inflate(getContext(), R.layout.item_farming_add_v2, null);
                    TextView tvName = view.findViewById(R.id.tv_name);
                    TextView tvStandard = view.findViewById(R.id.tv_standard);
                    TextView tv11 = view.findViewById(R.id.tv_11);
                    TextView tv12 = view.findViewById(R.id.tv_12);

                    tvName.setText(list1.get(i).getName());
                    if ("YES".equals(list1.get(i).getIsStandardEnforcement())) {
                        tvStandard.setVisibility(View.VISIBLE);
                        tvStandard.setText("按标准执行");
                    } else if ("NO".equals(list1.get(i).getIsStandardEnforcement())) {
                        tvStandard.setVisibility(View.VISIBLE);
                        tvStandard.setText("未按标准执行");
                    } else {
                        tvStandard.setVisibility(View.GONE);
                    }

                    tv11.setText("用量：" + list1.get(i).getUseNumber() + list1.get(i).getUnit());
                    tv12.setText("亩用量：" + list1.get(i).getMuNumber() + list1.get(i).getUnit());

                    layoutNongyaoAdd.addView(view);
                }

            } else {
                layoutParent1.setVisibility(View.GONE);
            }

            //化肥
            List<SchemaJsonVO> list2 = data.getAgriculturalOperationSchemeVO().getFertilizerSchemeList();
            if ((list2 != null && list2.size() > 0)) {
                layoutHuafeiAdd.removeAllViews();
                layoutParent2.setVisibility(View.VISIBLE);

                for (int i = 0; i < list2.size(); i++) {
                    View view = View.inflate(getContext(), R.layout.item_farming_add_v2, null);
                    TextView tvName = view.findViewById(R.id.tv_name);
                    TextView tvStandard = view.findViewById(R.id.tv_standard);
                    TextView tv11 = view.findViewById(R.id.tv_11);
                    TextView tv12 = view.findViewById(R.id.tv_12);

                    tvName.setText(list2.get(i).getName());
                    if ("YES".equals(list2.get(i).getIsStandardEnforcement())) {
                        tvStandard.setText("按标准执行");
                    } else {
                        tvStandard.setText("未按标准执行");
                    }

                    tv11.setText("用量：" + list2.get(i).getUseNumber() + "kg");
                    tv12.setText("亩用量：" + list2.get(i).getMuNumber() + "kg/亩");

                    layoutHuafeiAdd.addView(view);
                }

            } else {
                layoutParent2.setVisibility(View.GONE);
            }

            //大棚管理
            List<SchemaJsonVO> list3 = data.getAgriculturalOperationSchemeVO().getManageItemsRowsSchemeList();
            if ((list3 != null && list3.size() > 0)) {
                layoutDapengAdd.removeAllViews();
                layoutParent3.setVisibility(View.VISIBLE);

                for (int i = 0; i < list3.size(); i++) {
                    View view = View.inflate(getContext(), R.layout.item_farming_add_v2, null);
                    TextView tvName = view.findViewById(R.id.tv_name);
                    TextView tvStandard = view.findViewById(R.id.tv_standard);
                    TextView tv11 = view.findViewById(R.id.tv_11);
                    TextView tv12 = view.findViewById(R.id.tv_12);

                    tvName.setText(list3.get(i).getName());
                    if ("YES".equals(list3.get(i).getIsStandardEnforcement())) {
                        tvStandard.setText("按标准执行");
                    } else {
                        tvStandard.setText("未按标准执行");
                    }

                    tv11.setText("行数：" + list3.get(i).getRowsNumber() + "行");
                    tv12.setText("株数：" + list3.get(i).getTreeNumber() + "株");

                    layoutDapengAdd.addView(view);
                }

            } else {
                layoutParent3.setVisibility(View.GONE);
            }

            //机械设备
            List<SchemaJsonVO> list4 = data.getAgriculturalOperationSchemeVO().getMachineryEquipmentSchemeList();
            if ((list4 != null && list4.size() > 0)) {
                layoutJixieAdd.removeAllViews();
                layoutParent4.setVisibility(View.VISIBLE);

                for (int i = 0; i < list4.size(); i++) {
                    View view = View.inflate(getContext(), R.layout.item_farming_add_v2, null);
                    TextView tvName = view.findViewById(R.id.tv_name);
                    TextView tvStandard = view.findViewById(R.id.tv_standard);
                    TextView tv11 = view.findViewById(R.id.tv_11);
                    TextView tv12 = view.findViewById(R.id.tv_12);

                    tvName.setText(list4.get(i).getName());
                    if ("YES".equals(list4.get(i).getIsStandardEnforcement())) {
                        tvStandard.setText("按标准执行");
                    } else {
                        tvStandard.setText("未按标准执行");
                    }

                    tv11.setText("油耗：" + list4.get(i).getUseNumber() + "L");
                    tv12.setText("亩油耗：" + list4.get(i).getMuNumber() + "L/亩");

                    layoutJixieAdd.addView(view);
                }

            } else {
                layoutParent4.setVisibility(View.GONE);
            }

            //投入品
            List<SchemaJsonVO> list5 = data.getAgriculturalOperationSchemeVO().getInProductSchemeList();
            if ((list5 != null && list5.size() > 0)) {
                layoutTouruAdd.removeAllViews();
                layoutParent5.setVisibility(View.VISIBLE);

                for (int i = 0; i < list5.size(); i++) {
                    View view = View.inflate(getContext(), R.layout.item_farming_add_v2, null);
                    TextView tvName = view.findViewById(R.id.tv_name);
                    TextView tvStandard = view.findViewById(R.id.tv_standard);
                    TextView tv11 = view.findViewById(R.id.tv_11);
                    TextView tv12 = view.findViewById(R.id.tv_12);
                    View v2 = view.findViewById(R.id.v2);
                    LinearLayout layout2 = view.findViewById(R.id.layout2);
                    TextView tv21 = view.findViewById(R.id.tv_21);
                    TextView tv22 = view.findViewById(R.id.tv_22);


                    v2.setVisibility(View.VISIBLE);
                    layout2.setVisibility(View.VISIBLE);

                    tvName.setText(list5.get(i).getName());
                    if ("YES".equals(list5.get(i).getIsStandardEnforcement())) {
                        tvStandard.setText("按标准执行");
                    } else {
                        tvStandard.setText("未按标准执行");
                    }

                    tv11.setText("地膜：" + list5.get(i).getFilmNumber() + "kg");
                    tv12.setText("亩用量：" + list5.get(i).getFilmMuNumber() + "kg");
                    tv21.setText("滴灌带用量：" + list5.get(i).getDripDosage() + "m");
                    tv22.setText("亩用量：" + list5.get(i).getDripMuDosage() + "m");

                    layoutTouruAdd.addView(view);
                }

            } else {
                layoutParent5.setVisibility(View.GONE);
            }

            //技术方法-定值
            List<SchemaJsonVO> list9 = data.getAgriculturalOperationSchemeVO().getColonizationSchemeList();
            if ((list9 != null && list9.size() > 0)) {
                layoutDingzhiAdd.removeAllViews();
                layoutParent9.setVisibility(View.VISIBLE);

                for (int i = 0; i < list9.size(); i++) {
                    View view = View.inflate(getContext(), R.layout.item_farming_add_v2, null);
                    TextView tvName = view.findViewById(R.id.tv_name);
                    TextView tvStandard = view.findViewById(R.id.tv_standard);
                    TextView tv11 = view.findViewById(R.id.tv_11);
                    TextView tv12 = view.findViewById(R.id.tv_12);


                    tvName.setText(list9.get(i).getName());
                    if ("YES".equals(list9.get(i).getIsStandardEnforcement())) {
                        tvStandard.setText("按标准执行");
                    } else {
                        tvStandard.setText("未按标准执行");
                    }

                    tv11.setText("株数：" + list9.get(i).getUseNumber() + "个");
                    tv12.setText("亩株数：" + list9.get(i).getMuNumber() + "个/亩");

                    layoutDingzhiAdd.addView(view);
                }

            } else {
                layoutParent9.setVisibility(View.GONE);
            }

            //技术方法-育苗
            List<SchemaJsonVO> list6 = data.getAgriculturalOperationSchemeVO().getTechnicalMethodsSchemeList();
            if ((list6 != null && list6.size() > 0)) {
                layoutFangfaAdd.removeAllViews();
                layoutParent6.setVisibility(View.VISIBLE);

                for (int i = 0; i < list6.size(); i++) {
                    View view = View.inflate(getContext(), R.layout.item_farming_add_v2, null);
                    TextView tvName = view.findViewById(R.id.tv_name);
                    TextView tvStandard = view.findViewById(R.id.tv_standard);
                    TextView tv11 = view.findViewById(R.id.tv_11);
                    TextView tv12 = view.findViewById(R.id.tv_12);
                    View v2 = view.findViewById(R.id.v2);
                    LinearLayout layout2 = view.findViewById(R.id.layout2);
                    TextView tv21 = view.findViewById(R.id.tv_21);
                    TextView tv22 = view.findViewById(R.id.tv_22);
                    View v3 = view.findViewById(R.id.v3);
                    LinearLayout layout3 = view.findViewById(R.id.layout3);
                    TextView tv31 = view.findViewById(R.id.tv_31);
                    TextView tv32 = view.findViewById(R.id.tv_32);

                    v2.setVisibility(View.VISIBLE);
                    layout2.setVisibility(View.VISIBLE);
                    v3.setVisibility(View.VISIBLE);
                    layout3.setVisibility(View.VISIBLE);

                    tvName.setText(list6.get(i).getName());
                    if ("YES".equals(list6.get(i).getIsStandardEnforcement())) {
                        tvStandard.setText("按标准执行");
                    } else {
                        tvStandard.setText("未按标准执行");
                    }

                    tv11.setText("育苗：" + list6.get(i).getSeedlingNumber() + "个");
                    tv12.setText("穴盘：" + list6.get(i).getAcupointPlate() + "个");
                    tv21.setText("基质：" + list6.get(i).getMatrixDosage() + "袋");
                    tv22.setText("浇水：" + list6.get(i).getWateringNumber() + "次");
                    tv31.setText("种子：" + list6.get(i).getBagNum() + "袋");

                    String time;
                    if (!StringUtil.isStrEmpty(list6.get(i).getEmergenceTime()) && list6.get(i).getEmergenceTime().length() > 10)
                        time = list6.get(i).getEmergenceTime().substring(0, 10);
                    else
                        time = "";
                    tv32.setText("出苗时间：" + time);

                    layoutFangfaAdd.addView(view);
                }

            } else {
                layoutParent6.setVisibility(View.GONE);
            }

            //采收
            List<SchemaJsonVO> list7 = data.getAgriculturalOperationSchemeVO().getHarvestPackagingSchemeList();
            if ((list7 != null && list7.size() > 0)) {
                layoutCaishouAdd.removeAllViews();
                layoutParent7.setVisibility(View.VISIBLE);

                for (int i = 0; i < list7.size(); i++) {
                    View view = View.inflate(getContext(), R.layout.item_farming_add_v2, null);
                    TextView tvName = view.findViewById(R.id.tv_name);
                    TextView tvStandard = view.findViewById(R.id.tv_standard);
                    TextView tv11 = view.findViewById(R.id.tv_11);
                    TextView tv12 = view.findViewById(R.id.tv_12);
                    View v2 = view.findViewById(R.id.v2);
                    LinearLayout layout2 = view.findViewById(R.id.layout2);
                    TextView tv21 = view.findViewById(R.id.tv_21);
                    TextView tv22 = view.findViewById(R.id.tv_22);

                    v2.setVisibility(View.VISIBLE);
                    layout2.setVisibility(View.VISIBLE);

                    tvName.setText(list7.get(i).getName());
                    if ("YES".equals(list7.get(i).getIsStandardEnforcement())) {
                        tvStandard.setText("按标准执行");
                    } else {
                        tvStandard.setText("未按标准执行");
                    }

                    tv11.setText("采收重量：" + list7.get(i).getUseNumber() + "kg");
                    tv12.setText("亩采收重量：" + list7.get(i).getMuNumber() + "kg");
                    tv21.setText("包装规格：" + list7.get(i).getPackingSize());
                    tv22.setText("批次：" + list7.get(i).getBatch());

                    layoutCaishouAdd.addView(view);
                }

            } else {
                layoutParent7.setVisibility(View.GONE);
            }

            //加工
            List<SchemaJsonVO> list8 = data.getAgriculturalOperationSchemeVO().getProcessedPackagingSchemeList();
            if ((list8 != null && list8.size() > 0)) {
                layoutJiagongAdd.removeAllViews();
                layoutParent8.setVisibility(View.VISIBLE);

                for (int i = 0; i < list8.size(); i++) {
                    View view = View.inflate(getContext(), R.layout.item_farming_add_v2, null);
                    TextView tvName = view.findViewById(R.id.tv_name);
                    TextView tvStandard = view.findViewById(R.id.tv_standard);
                    TextView tv11 = view.findViewById(R.id.tv_11);
                    TextView tv12 = view.findViewById(R.id.tv_12);
                    View v2 = view.findViewById(R.id.v2);
                    LinearLayout layout2 = view.findViewById(R.id.layout2);
                    TextView tv21 = view.findViewById(R.id.tv_21);
                    TextView tv22 = view.findViewById(R.id.tv_22);
                    View v3 = view.findViewById(R.id.v3);
                    LinearLayout layout3 = view.findViewById(R.id.layout3);
                    TextView tv31 = view.findViewById(R.id.tv_31);
                    TextView tv32 = view.findViewById(R.id.tv_32);
                    View v4 = view.findViewById(R.id.v4);
                    LinearLayout layout4 = view.findViewById(R.id.layout4);
                    TextView tv41 = view.findViewById(R.id.tv_41);
                    TextView tv42 = view.findViewById(R.id.tv_42);

                    v2.setVisibility(View.VISIBLE);
                    layout2.setVisibility(View.VISIBLE);
                    v3.setVisibility(View.VISIBLE);
                    layout3.setVisibility(View.VISIBLE);
                    v4.setVisibility(View.VISIBLE);
                    layout4.setVisibility(View.VISIBLE);


                    tvName.setText(list8.get(i).getName());
                    if ("YES".equals(list8.get(i).getIsStandardEnforcement())) {
                        tvStandard.setText("按标准执行");
                    } else {
                        tvStandard.setText("未按标准执行");
                    }

                    tv11.setText("加工件数：" + list8.get(i).getProcessedNumber() + "个");
                    tv12.setText("加工重量：" + list8.get(i).getProcessedWeight() + "kg");
                    tv21.setText("人均加工件数：" + list8.get(i).getAvgProcessedNumber() + "个");
                    tv22.setText("包装箱（袋）：" + list8.get(i).getBoxNumber() + "个");
                    tv31.setText("冰袋：" + list8.get(i).getIcpPack() + "个");
                    tv32.setText("包装绳：" + list8.get(i).getPackingRope() + "斤");
                    tv41.setText("包装材料费：" + list8.get(i).getPackagingMaterialsFee() + "元");
                    tv42.setText("冷库预冷费：" + list8.get(i).getColdStorageFee() + "元");

                    layoutJiagongAdd.addView(view);
                }

            } else {
                layoutParent8.setVisibility(View.GONE);
            }
        }


//        getPesticideSchemeList() != null && getPesticideSchemeList().size() > 0
//        getManageItemsRowsSchemeList() != null && getManageItemsRowsSchemeList().size() > 0
//        getMachineryEquipmentSchemeList() != null && getMachineryEquipmentSchemeList().size() > 0
//        getInProductSchemeList() != null && getInProductSchemeList().size() > 0
//        getTechnicalMethodsSchemeList() != null && getTechnicalMethodsSchemeList().size() > 0
//        getHarvestPackagingSchemeList() != null && getHarvestPackagingSchemeList().size() > 0
//        getProcessedPackagingSchemeList() != null && getProcessedPackagingSchemeList().size() > 0


        //基础信息layout
        layoutJichu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (layoutJichuAdd.getVisibility() == View.VISIBLE) {
                    layoutJichuAdd.setVisibility(View.GONE);
                    layoutJichu.setBackgroundColor(getContext().getResources().getColor(R.color.colorFontLightGrayD));
                    tv1a.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    tv1b.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    iv1.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_shouqi));
                } else {
                    layoutJichuAdd.setVisibility(View.VISIBLE);
                    layoutJichu.setBackgroundColor(getContext().getResources().getColor(R.color.app_color));
                    tv1a.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    tv1b.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    iv1.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_zhankai));
                }
            }
        });

        //农药
        layoutNongyao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (layoutNongyaoAdd.getVisibility() == View.VISIBLE) {
                    layoutNongyaoAdd.setVisibility(View.GONE);
                    layoutNongyao.setBackgroundColor(getContext().getResources().getColor(R.color.colorFontLightGrayD));
                    tv2a.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    tv2b.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    iv2.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_shouqi));
                } else {
                    layoutNongyaoAdd.setVisibility(View.VISIBLE);
                    layoutNongyao.setBackgroundColor(getContext().getResources().getColor(R.color.app_color));
                    tv2a.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    tv2b.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    iv2.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_zhankai));
                }
            }
        });

        //化肥
        layoutHuafei.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (layoutHuafeiAdd.getVisibility() == View.VISIBLE) {
                    layoutHuafeiAdd.setVisibility(View.GONE);
                    layoutHuafei.setBackgroundColor(getContext().getResources().getColor(R.color.colorFontLightGrayD));
                    tv3a.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    tv3b.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    iv3.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_shouqi));
                } else {
                    layoutHuafeiAdd.setVisibility(View.VISIBLE);
                    layoutHuafei.setBackgroundColor(getContext().getResources().getColor(R.color.app_color));
                    tv3a.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    tv3b.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    iv3.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_zhankai));
                }
            }
        });

        //大棚管理
        layoutDapeng.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (layoutDapengAdd.getVisibility() == View.VISIBLE) {
                    layoutDapengAdd.setVisibility(View.GONE);
                    layoutDapeng.setBackgroundColor(getContext().getResources().getColor(R.color.colorFontLightGrayD));
                    tv4a.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    tv4b.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    iv4.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_shouqi));
                } else {
                    layoutDapengAdd.setVisibility(View.VISIBLE);
                    layoutDapeng.setBackgroundColor(getContext().getResources().getColor(R.color.app_color));
                    tv4a.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    tv4b.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    iv4.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_zhankai));
                }
            }
        });

        //机械设备
        layoutJixie.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (layoutJixieAdd.getVisibility() == View.VISIBLE) {
                    layoutJixieAdd.setVisibility(View.GONE);
                    layoutJixie.setBackgroundColor(getContext().getResources().getColor(R.color.colorFontLightGrayD));
                    tv5a.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    tv5b.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    iv5.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_shouqi));
                } else {
                    layoutJixieAdd.setVisibility(View.VISIBLE);
                    layoutJixie.setBackgroundColor(getContext().getResources().getColor(R.color.app_color));
                    tv5a.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    tv5b.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    iv5.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_zhankai));
                }
            }
        });

        //投入品
        layoutTouru.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (layoutTouruAdd.getVisibility() == View.VISIBLE) {
                    layoutTouruAdd.setVisibility(View.GONE);
                    layoutTouru.setBackgroundColor(getContext().getResources().getColor(R.color.colorFontLightGrayD));
                    tv6a.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    tv6b.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    iv6.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_shouqi));
                } else {
                    layoutTouruAdd.setVisibility(View.VISIBLE);
                    layoutTouru.setBackgroundColor(getContext().getResources().getColor(R.color.app_color));
                    tv6a.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    tv6b.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    iv6.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_zhankai));
                }
            }
        });

        //技术方法-定值
        layoutDingzhi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (layoutDingzhiAdd.getVisibility() == View.VISIBLE) {
                    layoutDingzhiAdd.setVisibility(View.GONE);
                    layoutDingzhi.setBackgroundColor(getContext().getResources().getColor(R.color.colorFontLightGrayD));
                    tv10a.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    tv10b.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    iv10.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_shouqi));
                } else {
                    layoutDingzhiAdd.setVisibility(View.VISIBLE);
                    layoutDingzhi.setBackgroundColor(getContext().getResources().getColor(R.color.app_color));
                    tv10a.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    tv10b.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    iv10.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_zhankai));
                }
            }
        });

        //技术方法-育苗
        layoutFangfa.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (layoutFangfaAdd.getVisibility() == View.VISIBLE) {
                    layoutFangfaAdd.setVisibility(View.GONE);
                    layoutFangfa.setBackgroundColor(getContext().getResources().getColor(R.color.colorFontLightGrayD));
                    tv7a.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    tv7b.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    iv7.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_shouqi));
                } else {
                    layoutFangfaAdd.setVisibility(View.VISIBLE);
                    layoutFangfa.setBackgroundColor(getContext().getResources().getColor(R.color.app_color));
                    tv7a.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    tv7b.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    iv7.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_zhankai));
                }
            }
        });

        //采收
        layoutCaishou.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (layoutCaishouAdd.getVisibility() == View.VISIBLE) {
                    layoutCaishouAdd.setVisibility(View.GONE);
                    layoutCaishou.setBackgroundColor(getContext().getResources().getColor(R.color.colorFontLightGrayD));
                    tv8a.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    tv8b.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    iv8.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_shouqi));
                } else {
                    layoutCaishouAdd.setVisibility(View.VISIBLE);
                    layoutCaishou.setBackgroundColor(getContext().getResources().getColor(R.color.app_color));
                    tv8a.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    tv8b.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    iv8.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_zhankai));
                }
            }
        });

        //加工
        layoutJiagong.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (layoutJiagongAdd.getVisibility() == View.VISIBLE) {
                    layoutJiagongAdd.setVisibility(View.GONE);
                    layoutJiagong.setBackgroundColor(getContext().getResources().getColor(R.color.colorFontLightGrayD));
                    tv9a.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    tv9b.setTextColor(getContext().getResources().getColor(R.color.colorFontBlack));
                    iv9.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_shouqi));
                } else {
                    layoutJiagongAdd.setVisibility(View.VISIBLE);
                    layoutJiagong.setBackgroundColor(getContext().getResources().getColor(R.color.app_color));
                    tv9a.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    tv9b.setTextColor(getContext().getResources().getColor(R.color.colorWhite));
                    iv9.setBackground(getContext().getResources().getDrawable(R.drawable.ic_farming_zhankai));
                }
            }
        });


        tvEdit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                callBack.edit(getAdapterPosition());
            }
        });

        tvDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                callBack.del(getAdapterPosition());
            }
        });
    }

}
